package com.example.demo.sender;

import com.example.demo.Order;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 发件者A（生产者A）
 */
@Component
public class SenderA {
    @Autowired
    private AmqpTemplate amqpTemplate;
    @Autowired
    private OrderSender orderSender;

    public void send(String content) {
        System.out.println("Sender A:" + content);
        this.amqpTemplate.convertAndSend("queue1", content);
    }

    public void send1() {
        String content = "color.red";
        System.out.println("sender:" + content);
        this.amqpTemplate.convertAndSend("topicExchange","color.red",  content);
    }
    public void send2() {
        String content = "color.blue";
        System.out.println("sender:" + content);
        this.amqpTemplate.convertAndSend("topicExchange","color.blue", content);
    }
    public void send3() {
        String content = "color.green";
        System.out.println("sender:" + content);
        this.amqpTemplate.convertAndSend("topicExchange","color.green", content);
    }

    public void send4() {
        String content = "fanout ";
        System.out.println("sender:" + content);
        this.amqpTemplate.convertAndSend("fanoutExchange","", content);
    }


}
